
#include "./common.h"
FILE *fp;

int multu(unsigned long a,unsigned long b,unsigned int reflo,unsigned int refhi){
    unsigned long c=a*b;
    unsigned tmplo = (unsigned) (c&0xffffffff);
    unsigned tmphi = (unsigned) (c>>32);
    return tmplo==reflo && tmphi == refhi;
}

void gen_msubu(){

    fprintf(fp,"TEST_MType(");
    unsigned long a=(unsigned long)getRandInt32();
    unsigned long b=(unsigned long)getRandInt32();
    a=0;
    long oldlo=(long)getRandInt32();
    long oldhi=(long)getRandInt32();
    unsigned long c = a*b;
    c=((oldhi<<32)+oldlo)-c;
    unsigned tmplo=(unsigned)(c&0xffffffff);
    unsigned tmphi=(unsigned)(c>>32);
    fprintf(fp,"0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,0x%08x,msubu)\n",(unsigned)a,(unsigned)b,tmplo,tmphi,(int)oldlo,(int)oldhi);
}

int main(int argc, char const *argv[])
{
    fp=fopen("../asm/msubu.S","w");
    srand(time(NULL));
    for (int i = 0; i < 50; i++)
    {
        gen_msubu();
    }

    return 0;
}
